package org.dydl.dao.system.repository;

import java.util.List;

import org.dydl.model.system.AreaProductList;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

@Repository
public interface IAreaProductListRepository extends CrudRepository<AreaProductList, Integer>,
		JpaSpecificationExecutor<AreaProductList> {

	@Query(value = "SELECT * FROM areaproductlist WHERE AREA_ID = :areaId AND BUSINESS_ID = :businessId ORDER BY CREATE_TIME DESC",nativeQuery=true)
	List<AreaProductList> getAreaProductList(@Param("areaId") Integer areaId ,@Param("businessId") String businessId);
	
	@Query(value = "SELECT * FROM areaproductlist WHERE PRODUCT_NAME LIKE %:name%" , nativeQuery = true)
	List<AreaProductList> get(@Param("name") String name);
	
	@Query(value = "SELECT * FROM areaproductlist WHERE BUSINESS_ID = :businessId ORDER BY CREATE_TIME DESC",nativeQuery=true)
	List<AreaProductList> findByBusinessId(@Param("businessId") String businessId);

}
